import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClassInfoVO, ClassInfoForm, ClassInfoQuery } from '@/api/office/class/types';

/**
 * 查询班级信息列表
 * @param query
 * @returns {*}
 */

export const listClassInfo = (query?: any): AxiosPromise<any[]> => {
  return request({
    url: '/office/class/list',
    method: 'get',
    params: query
  });
};

export const pageClassInfo = (query?: any): AxiosPromise<any[]> => {
  return request({
    url: '/office/class/page',
    method: 'get',
    params: query
  });
};

/**
 * 查询班级信息详细
 * @param id
 */
export const getClassInfo = (id: string | number): AxiosPromise<ClassInfoVO> => {
  return request({
    url: '/office/class/' + id,
    method: 'get'
  });
};

/**
 * 新增班级信息
 * @param data
 */
export const addClassInfo = (data: ClassInfoForm) => {
  return request({
    url: '/office/class',
    method: 'post',
    data: data
  });
};

/**
 * 修改班级信息
 * @param data
 */
export const updateClassInfo = (data: ClassInfoForm) => {
  return request({
    url: '/office/class',
    method: 'put',
    data: data
  });
};

/**
 * 删除班级信息
 * @param id
 */
export const delClassInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/office/class/' + id,
    method: 'delete'
  });
};

export const classTree = (): AxiosPromise<any[]> => {
  return request({
    url: '/office/class/tree',
    method: 'get'
  });
};
